package simulation;

import model.DrawCommand;

/**
 * @author  Owner
 */
public class Visualizer {

	private static Visualizer visualizer;
	private Mover mover;

	private Visualizer() {
	}
	public static Visualizer getInstance(){
		if(visualizer==null){
			visualizer=new Visualizer();
			return visualizer;
		}
		else{
			return visualizer;
		}
	}
	
	public void visualSwap(DrawCommand swap) throws InterruptedException {
		int firstInd = swap.getSwappedA();
		int secondInd = swap.getSwappedB();
//		System.out.println("Swap "+swap.getSwappedA()+" with "+ swap.getSwappedB());
		mover = new Mover(firstInd , secondInd);
		Thread thread =new Thread(mover);
		thread.start();
		thread.join();
	}
	
	public void pauseSimulation(){
	    mover.pause();
	}
	
	public void resumeSimulation(){
	    mover.resume();
	}
	public void skipSimulation(){
	    mover.skip();
	}
}
